Skip to content

AO3-6960 Admin post drafts and previews#5822

Open
marcus8448 wants to merge 8 commits into
otwcode:masterfrom
marcus8448:AO3-6960
Open

AO3-6960 Admin post drafts and previews#5822
marcus8448 wants to merge 8 commits into
otwcode:masterfrom
marcus8448:AO3-6960

Conversation

@marcus8448
Copy link
Copy Markdown
Member

Issue

https://otwarchive.atlassian.net/browse/AO3-6960

Purpose

Allows admins to save unpublished (draft) admin posts and preview changes before publication.

Testing Instructions

Manual QA steps TBD.

Credit

marcus8448 (he/him)

@github-actions github-actions Bot added Has Migrations Contains migrations and therefore needs special attention when deploying Awaiting Review labels May 17, 2026
Copy link
Copy Markdown
Contributor

@pmonfort pmonfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! The code looks good. Tested locally and the core flow works well. Left a few comments, mostly small things.

end
@admin_posts = @admin_posts.order('created_at DESC').page(params[:page])
@page_subtitle = t(".page_title")
@admin_posts = @admin_posts.posted.order(published_at: :desc).page(params[:page])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses will_paginate, but drafts below uses pagy. Should this also use pagy for consistency?

if @admin_post.save
flash[:notice] = ts("Admin Post was successfully created.")
redirect_to(@admin_post)
if params[:preview_button]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that the post is valid before previewing? Something similar to what's done in update where @admin_post.valid? is checked before previewing the post.

@admin_post = AdminPost.find(params[:id])
authorize @admin_post

@admin_post.posted = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check @admin_post&.translated_post&.draft? like we do in create and update to avoid potential bugs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a validation to the model to prevent translations from being posted first, which should cover this and also prevent already published posts from turned into translations of a draft post.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great approach, thanks for taking care of that!

Comment thread app/views/admin/_admin_nav.html.erb Outdated
<%= span_if_current t(".ao3_news"), admin_posts_path %>
</li>
<li>
<%= span_if_current t(".ao3_news_drafts"), drafts_admin_posts_path %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "AO3 News Drafts" link is shown without a permission check. The ticket says it should be visible to "any admin with a role listed in the AdminPostPolicy section." Should this be wrapped in <% if policy(AdminPost).can_draft? %> like the other links?

<% end %>

<% if @preview_mode %>
<li><%= form.submit t(".actions.edit"), name: "edit_button" %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing </li> closing tag here.

@admin @comments
Feature: Admin Actions to Draft News
In order to post news items
As an an admin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: double "an"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting Review Has Migrations Contains migrations and therefore needs special attention when deploying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants